// ******************************************************************
// * Copyright(c)  Steven Lu
// * Description   : Entity_PROD_TECHNIC
// * CreateDate    : 2011/8/16 10:16:41
// * Creater       : CodeSmith
// * LastChangeDate: 2011/8/16 10:16:41
// * LastChanger   : 2011/8/16 10:16:41
// * Version Info  : 1.0 For ESOL
// ******************************************************************

using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Suzsoft.Smart.Data;
using ESOL.Common.Entity;
using ESOL.Common;

namespace ESOL.Business.Prod
{
/// <summary>
    /// ProdTechnic
    /// </summary>
    public partial class ProdTechnicBs
    {
        #region GetByID
        /// <summary>
        /// Get Entity
        /// </summary>
        /// <param name="objProdTechnicEntity">Entity</param>
        /// <returns>Entity</returns>
        public static ProdTechnicEntity GetProdTechnic(ProdTechnicEntity objProdTechnicEntity)
        {
            return DataAccess.SelectSingle<ProdTechnicEntity>(objProdTechnicEntity);
        }

        #endregion


        #region Insert
        /// <summary>
        /// Insert Data
        /// </summary>
        /// <param name="objProdTechnicEntity">Entity</param>
        /// <returns>true Insert Succeed; false Insert Fail</returns>
        public static bool InsertProdTechnic(ProdTechnicEntity objProdTechnicEntity)
        {
            return DataAccess.Insert(objProdTechnicEntity);
        }

        public static bool InsertProdTechnic(List<ProdTechnicEntity> objProdTechnicEntityList)
        {
            return DataAccess.Insert(objProdTechnicEntityList);
        }
        #endregion


        #region Update
        /// <summary>
        /// Update Data
        /// </summary>
        /// <param name="objProdTechnicEntity">Entity</param>
        /// <returns>true Update Succeed; false Update Fail</returns>
        public static bool UpdateProdTechnic(ProdTechnicEntity objProdTechnicEntity)
        {
            return DataAccess.Update(objProdTechnicEntity);
        }

        public static bool UpdateProdTechnic(List<ProdTechnicEntity> objProdTechnicEntityList)
        {
            return DataAccess.Update<ProdTechnicEntity>(objProdTechnicEntityList);
        }
        #endregion


        #region Delete
        /// <summary>
        /// Delete Data
        /// </summary>
        /// <param name="objProdTechnicEntity">Entity</param>
        /// <returns>true Delete Succeed; false Delete Fail</returns>
        public static bool DeleteProdTechnic(ProdTechnicEntity objProdTechnicEntity)
        {
            return DataAccess.Delete(objProdTechnicEntity);
        }

        public static bool DeleteProdTechnic(List<ProdTechnicEntity> objProdTechnicEntityList)
        {
            return DataAccess.Delete<ProdTechnicEntity>(objProdTechnicEntityList);
        }
        #endregion


        #region GetAll
        /// <summary>
        /// Get All Data
        /// </summary>
        /// <returns>Back All Data<returns>
        public static DataSet GetProdTechnicAll()
        {
            return DataAccess.SelectAllDataSet<ProdTechnicEntity>();
        }
        /// <summary>
        /// Get All Data List
        /// </summary>
        /// <returns>Back All Data List<returns>
        public static List<ProdTechnicEntity> GetProdTechnicAllList()
        {
            return DataAccess.SelectAll<ProdTechnicEntity>();
        }
        #endregion

        #region Functions
        public static ProdTechnicEntity GetProdTechnicByID(string TechnicID)
        {
            if (string.IsNullOrEmpty(TechnicID))
                return null;
            ProdTechnicEntity m = new ProdTechnicEntity();
            m.TechnicId = TechnicID;
            return DataAccess.SelectSingle<ProdTechnicEntity>(m);
        }

        public static DataTable GetProdTechnicByCondition(string rowCount, string condition, string orderBy)
        {
            string sql = CommonFunctions.GetSelect(rowCount) + @"A.*,MSG.GROUP_NAME FROM PROD_TECHNIC A 
                LEFT JOIN MST_WORKING_GROUP MSG ON A.GROUP_ID=MSG.GROUP_ID WHERE 1=1 ";
            if (string.IsNullOrEmpty(condition) == false)
            {
                sql += condition;
            }
            if (string.IsNullOrEmpty(orderBy) == false)
            {
                sql += " ORDER BY " + orderBy;
            }
            DataSet ds = DataAccess.SelectDataSet(sql);
            if (ds != null && ds.Tables.Count > 0)
            {
                return ds.Tables[0];
            }
            return null;
        }

        public static ProdTechnicEntity GetProdTechnicByProductTechnicID(string ProductTechnicID)
        {
            if (string.IsNullOrEmpty(ProductTechnicID))
                return null;
            string Sql=@"SELECT PT.* FROM PROD_PRODUCT_TECHNIC PPT INNER JOIN PROD_TECHNIC PT
                ON PPT.TECHNIC_ID=PT.TECHNIC_ID 
                WHERE PPT.PRODUCT_TECHNIC_ID='" + ProductTechnicID + "' ";
            List<ProdTechnicEntity> list=DataAccess.Select<ProdTechnicEntity>(Sql);
            if (list != null && list.Count > 0)
                return list[0];
            else return null;
        }

        public static ProdTechnicEntity GetProdTechnicByTechnicCode(string TechnicCode)
        {
            if (string.IsNullOrEmpty(TechnicCode))
                return null;
            ProdTechnicEntity m = new ProdTechnicEntity();
            m.TechnicCode = TechnicCode;
            return DataAccess.SelectSingle<ProdTechnicEntity>(m);
        }
        #endregion
    }
	
	
}	

